<?php
namespace Home\Controller;
use Think\Controller;
/**
 * 后台意见反馈
 */
class FeedbackController extends CommonController {
	/**
	 * [意见反馈页]
	 * @Author   Axing
	 * @DateTime 2017-09-07
	 * @return   [type]     [description]
	 */
	public function index() {
		$page = $this->page($_POST['pageNum'], $_POST['numPerPage']);
		$list = $this->lists($page['currentPage'], $page['numPerPage']);
		$this->assign('list', $list);
		$this->assign('pages', $page);
		$this->display();
	}

	/**
	 * [列表数据]
	 * @Author   Axing
	 * @DateTime 2017-09-07
	 * @return   [array]     [列表数据]
	 */
	public function lists() {
		$row = D('Feedback')->lists();
		return $row;
	}

	/**
	 * [分页数据]
	 * @Author   Axing
	 * @DateTime 2017-09-07
	 * @param    string     $currentPage [description]
	 * @param    string     $numPerPage  [description]
	 * @return   [type]                  [description]
	 */
	public function page($currentPage='', $numPerPage='') {
		$row = D('Feedback')->lists();
		$pages['total'] = count($row);

		$currentPage = empty($currentPage) || is_null($currentPage)?1:$currentPage;
		$numPerPage = empty($numPerPage) || is_null($numPerPage)?100:$numPerPage;

		if($currentPage != 1) {
			$pages['currentPage'] = $currentPage*$numPerPage;
			$pages['numPerPage'] = $numPerPage;
		} else {
			$pages['currentPage'] = $currentPage;
			$pages['numPerPage'] = $numPerPage;
		}
		return $pages;
	}

	/**
	 * [删除数据]
	 * @Author   Axing
	 * @DateTime 2017-09-07
	 * @return   [type]     [description]
	 */
	public function del() {
		$id = implode(',', I('id'));

		$res = M('Feedback')->where('id IN (' . $id . ')')->delete();
        $returnArr = array(
            "code"=>200,
            "msg"=>"删除成功"
        );

        $this->ajaxReturn($returnArr);
	}
}